package gecko.view.swing;

import gecko.control.CtrlGecko;
import gecko.view.IObservable;

import java.awt.*;
import java.sql.SQLException;

import javax.swing.*;

public class VLogin extends JFrame implements IObservable {

    private static final long serialVersionUID = 1L;
	private CtrlGecko controleur;
    private JPanel pPrinc;
    private JLabel lEntete;
    private JLabel lMenu;
    private JLabel lCorps;
    private JLabel lPied;
    public JTextField tfUser;
    private JPasswordField tfPass;
    
    
    private void place() {

        this.setSize(1440, 900);
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        this.setVisible(true);
    }
    
    public VLogin(CtrlGecko controleur) {

        // Creation d'une fenetre
        super("GECKO - 2014");

        // Ajout Controleur
        this.setControleur(controleur);

        // Creation et Ajout des composants
        pPrinc = new JPanel();
        pPrinc.setBorder(BorderFactory.createEmptyBorder(-6, 0, 0, 0));        
        
        lEntete = new JLabel(new ImageIcon("images/background/entete.png"));
        lEntete.setBorder(BorderFactory.createEmptyBorder(-2, 0, -5, 0));        
        
        lMenu = new JLabel(new ImageIcon("images/background/menu.png"));
        
        lCorps = new JLabel(new ImageIcon("images/background/corpsLogin.png")); 
        lCorps.setLayout(new FlowLayout()); 

        JLabel lUser = new JLabel("Utilisateur");
        tfUser = new JTextField(20);
        JLabel lPass = new JLabel("Mot de passe");
        tfPass = new JPasswordField(20);
        
        JButton bOK = new JButton(new ImageIcon("images/boutons/blanc/OK_B.png"));
        bOK.setActionCommand("OK_Login");
        this.getRootPane().setDefaultButton(bOK);
        bOK.addActionListener(getControleur());
        bOK.setBorder(null);
        bOK.setBorderPainted(false);
        bOK.setContentAreaFilled(false);

        lCorps.add(lUser);
        lCorps.add(tfUser);
        lCorps.add(lPass);
        lCorps.add(tfPass);  
        lCorps.add(bOK);
        lCorps.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));   
        
        lPied = new JLabel(new ImageIcon("images/background/piedpage.png"));
            
        pPrinc.add(lEntete);
        pPrinc.add(lMenu);
        pPrinc.add(lCorps);
        pPrinc.add(lPied);

        // Ajout de ces conteneurs au conteneur de ma fenetre
        this.add(pPrinc);

        // Assemblage de la fenetre
        this.pack();

        // Affichage de cette fenetre
        this.place();

    }
    
    public String getUtilisateur(){
		return tfUser.getText().trim();
    }
    
    public String getPassword(){
		return tfPass.getText().trim();
    }
    
    public String toString() {
		return "User : "+ getUtilisateur()+" / Pass : "+getPassword();
	}

	public CtrlGecko getControleur() {
		return controleur;
	}

	public void setControleur(CtrlGecko controleur) {
		this.controleur = controleur;
	}

	@Override
	public String getSaisieService() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieNom() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieNumero() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieVille() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieCP() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getIDServ() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getIDTypo() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieTypo() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getService() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getFourn() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getTypo() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSign() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getLbl() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public boolean getActif() {
		// TODO Auto-generated method stub
		return false;
	}

	@Override
	public String getDelai() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getIDFourn() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieSign() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieLib() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String recupService(String resultService) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieRue() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getJour() {
		// TODO Auto-generated method stub
		return null;
	}


	@Override
	public JTable getTab() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getSaisieAdresse() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getAnneeFin() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getMoisFin() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getMois() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getAnnee() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getJourFin() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String importer() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getIDContrat() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public VTab getMod() {
		// TODO Auto-generated method stub
		return null;
	}

	
}
